<template>
	<view>
		<u-navbar title="修改登录密码"></u-navbar>
		<view class="u-m-x-50">
			<view class="u-m-t-50 input-wrap">
				<input class="input" type="password" v-model="password" placeholder="请输入新密码" placeholder-class="placeholder"/>
			</view>
			<view class="u-m-t-50 input-wrap">
				<input class="input" type="password" v-model="confirmPwd" placeholder="请输入确认密码" placeholder-class="placeholder"/>
			</view>
		</view>
		<view class="next u-m-t-50" @tap="save">
			完成
		</view>
	</view>
</template>

<script>
	import { resetPassword } from '@/api/user';
	import { delay, goback, toast } from '@/utils/util';
	export default {
		data() {
			return {
				password:'',
				confirmPwd:'', 
				lock:false,
			};
		},
		methods:{
			async save(){
				if(this.lock){
					return
				}
				if(this.confirmPwd!=this.password){
					return toast('两次密码不一致')
				}
				try{
					this.lock = true
					await resetPassword({
						password:this.password
					})
					uni.showToast({
						title:"提交成功"
					})
					await delay(1000)
					goback()
				}finally{
					this.lock = false
				}
			}
		}
	}
</script>
<style>
	page{
		background-color: #FFFFFF;
	}
</style>
<style lang="scss">
	.input-wrap{
		padding: 20rpx;
		background-color: #F5F5F5;
		border-radius: 20rpx;
	}
	.next{
		margin-left: auto;
		margin-right: auto;
		font-size: 36rpx;
		font-weight: bold;
		width: 340rpx;
		height: 90rpx;
		border-radius: 200rpx;
		background-color: $theme-color;
		color: #000000;
		display: flex;
		align-items: center;
		justify-content: center;
		&.disable{
			background-color: #F0F0F0;
			color: #AAAAAA;
		}
	}
</style>
